#include <stdio.h>
#define N 1000
int arr4[N+1]= {0};

int main_20()
{
    int n;
    scanf("%d",&n);
    for (int i=0; i<n ; i++ )
    {
        scanf("%d",&arr4[i]);
    }
    for (int i=0; i<n ; i++ )
    {
        int less=0,more=0;
        for (int j=0; j<n ; j++ )
        {
            if (arr4[i]<arr4[j])
            {
                more++;
            }
            else if(arr4[i]>arr4[j])
            {
                less++;
            }
        }
        if (less==more)
        {
            printf("%d\n",arr4[i]);
            return 0;
        }
    }
    printf("%d",-1);
    return 0;
}
